package com.tensquare.recruit.controller;

import com.tensquare.recruit.pojo.Recruit;
import com.tensquare.recruit.service.RecruitService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("recruit")
public class RecruitController {
    @Autowired
    private RecruitService recruitService;

    /**
     * 1.查询推荐列表信息
     * @return  招聘信息
     */
    @GetMapping("search/recommend")
    public Result recommend(){
        try {
            List<Recruit> recruitList = recruitService.recommend();
            return new Result(StatusCode.OK,true,"查询推荐列表成功！",recruitList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(StatusCode.ERROR,false,"查询推荐列表失败！");
        }
    }

    /**
     * 2.查询最新的招聘信息
     * @return 招聘信息
     */
    @GetMapping("search/newlist")
    public Result newlist(){
        try {
            List<Recruit> recruitList = recruitService.newlist();
            return new Result(StatusCode.OK,true,"查询最新的招聘列表成功！",recruitList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(StatusCode.ERROR,false,"查询最新的招聘列表失败！");
        }
    }
}
